<?php

/**
 * JavaScript layer class
 * 
 * @package DeadTouch AAC
 * @version 0.0.1
 * @author Kofel <kofels@gmail.com>
 * @copyright 2008 (C) by Kofel
 * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3
 * @todo 
 */
 
class jsLayer
{
	private $Files = array();
	private $CodePieces = array();
	
	public function addCode( $code )
	{
		$this->CodePieces[] = $code;
	}
	
	public function addFile( $file )
	{
		$this->Files[] = $file;
	}
	
	public function get()
	{
		$Output = '';
		
		foreach( $this->Files as $f )
		{
			$Output .= '<script type="text/javascript" src="' . $f . '"></script>';
		}
		if( count( $this->CodePieces ) )
		{
			$Output .= "<script type=\"text/javascript\"> <!--\n";
			
			foreach( $this->CodePieces as $code )
			{
				$Output .= "\n" . $code . "\n";

			}
			
			$Output .= "\n// --> </script>";
		}

		
		return $Output;
	}
	
	public function load()
	{
		$this->addFile('js/jquery.js');
		$this->addFile('js/thickbox.js');
	}
}
?>